home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / PROGRAMS / CH4 / 4-3-2.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-09-18  |  2.1 KB  |  72 lines

  1. VERSION 5.00
  2. Begin VB.Form frm4_3_2 
  3.    Caption         =   "Extract First Name"
  4.    ClientHeight    =   1920
  5.    ClientLeft      =   1425
  6.    ClientTop       =   1620
  7.    ClientWidth     =   3825
  8.    BeginProperty Font 
  9.       Name            =   "MS Sans Serif"
  10.       Size            =   8.25
  11.       Charset         =   0
  12.       Weight          =   700
  13.       Underline       =   0   'False
  14.       Italic          =   0   'False
  15.       Strikethrough   =   0   'False
  16.    EndProperty
  17.    LinkTopic       =   "Form1"
  18.    PaletteMode     =   1  'UseZOrder
  19.    ScaleHeight     =   1920
  20.    ScaleWidth      =   3825
  21.    Begin VB.CommandButton cmdDetermine 
  22.       Caption         =   "Determine First Name"
  23.       Default         =   -1  'True
  24.       Height          =   495
  25.       Left            =   480
  26.       TabIndex        =   2
  27.       Top             =   720
  28.       Width           =   2775
  29.    End
  30.    Begin VB.PictureBox picFirstName 
  31.       Height          =   255
  32.       Left            =   120
  33.       ScaleHeight     =   195
  34.       ScaleWidth      =   3555
  35.       TabIndex        =   3
  36.       Top             =   1440
  37.       Width           =   3615
  38.    End
  39.    Begin VB.TextBox txtFullName 
  40.       Height          =   285
  41.       Left            =   840
  42.       TabIndex        =   1
  43.       Top             =   240
  44.       Width           =   2895
  45.    End
  46.    Begin VB.Label lblName 
  47.       Caption         =   "Name"
  48.       Height          =   255
  49.       Left            =   120
  50.       TabIndex        =   0
  51.       Top             =   240
  52.       Width           =   615
  53.    End
  54. Attribute VB_Name = "frm4_3_2"
  55. Attribute VB_GlobalNameSpace = False
  56. Attribute VB_Creatable = False
  57. Attribute VB_PredeclaredId = True
  58. Attribute VB_Exposed = False
  59. Private Sub cmdDetermine_Click()
  60.   Dim nom As String
  61.   'Determine a person's first name
  62.   nom = txtFullName.Text
  63.   picFirstName.Cls
  64.   picFirstName.Print "The first name is "; FirstName(nom)
  65. End Sub
  66. Private Function FirstName(nom As String) As String
  67.   Dim firstSpace As Integer
  68.   'Extract the first name from a full name
  69.   firstSpace = InStr(nom, " ")
  70.   FirstName = Left(nom, firstSpace - 1)
  71. End Function
  72.